<template>
  <starGenView :title="'hierTest'">
    <!-- hierList -->
    <Card class="ivu-mb" title="hierList">
      <cfgHierList :hierObject="hierObjectList" ref="_list"/>
      <Button @click="submit1">submit</Button>
    </Card>
    <!-- hierDictionary -->
    <Card class="ivu-mb" title="hierDictionary">
      <cfgHierDictionary :hierObject="hierObjectDic" />
      <Button @click="submit2">submit</Button>
    </Card>
    <!-- hierTree -->
    <Card class="ivu-mb" title="hierTree">
      <cfgHierTree :hierObject="hierObjectTree"/>
      <Button @click="submit3">submit</Button>
    </Card>
  </starGenView>
</template>

<script>
import listModel from 'public/model/model/hier/listModel'
import dictionaryModel from 'public/model/model/hier/dictionaryModel'
import treeModel from 'public/model/model/hier/treeModel'
import {hierList, hierDic, hierTree } from './config'

export default {
  name: "hierTest",
  data() {
    return {
      hierObjectList: null,
      hierObjectDic: null,
      hierObjectTree: null,
      treeData: []
    }
  },
  created() {
      this.hierObjectList = new listModel(hierList),
      this.hierObjectDic = new dictionaryModel(hierDic)
      this.hierObjectTree = new treeModel(hierTree)
  },
  methods: {
    // 提交添加或修改数据
    submit1() {
      let res = this.$refs._list.getValues()
      console.log("🚀 ~ file: hierTest.vue:69 ~ submit1 ~ res:", res)
      console.log(JSON.stringify(this.hierObjectList.hierProperties, null, 4));
    },
    submit2() {
      console.log(JSON.stringify(this.hierObjectDic.hierProperties, null, 4));
    },
    submit3() {
      console.log(JSON.stringify(this.hierObjectTree.hierProperties, null, 4));
    },
  },
  props: {
    drawer: {
      default: () => {
        return {
          status: 'edit', // new edit read
          show: true,
        };
      }
    },
    hierObject: {
      default() {
        return null
      }
    },
  },
}
</script>
